<?php
/*
 * 手机客户端 用户信息处理函数
 * 2013-11-26
 */
 
 
 /**
  * 通过UUID获取对应的用户信息
  */
 function user_getInfoFromUUID(){
	$uuid = $_REQUEST["uuid"];	//动态用户主键
	if(!$uuid){
		return null;
	}
	$dbf = $GLOBALS['dbf'];
	//查询用户信息
	$sql = "select uid,realname,mobile,urank,ustatus from user_base where muuid='".trim($uuid)."'";
	$reArr = $dbf->queryArray($sql);
	if($reArr && count($reArr)>0){
		return $reArr[0];
	}
	return null;
 }
 
 /**
  * 用户关注数
  */
 function user_attentionCount($uid){
	$sql = "select count(0) as ct from user_concern where uid='".$uid."'";
	$dbf = $GLOBALS['dbf'];
	$dbf->query($sql);
	
	if($dbf->next_record()){
		return $dbf->f("ct");
	}
	return 0;
 }
 
 /**
  * 用户专注信息id序列
  */
 function user_gzids($uid){
	$sql = "select aid from user_concern where uid='".$uid."' and aid<>''";
	$dbf = $GLOBALS['dbf'];
	$dbf->query($sql);
	$reStr = ""; //构建返回值
	while($dbf->next_record()){
		if($reStr){
			$reStr = $reStr.",";
		}
		$reStr = $reStr.$dbf->f("aid");
	}
	return $reStr;
 }
 
  /**
   * 用户关注信息序列
   */
  function user_gzlist($aids){
	if(!$aids){
		$aids = "0";
	}
	$sql = "select
					date_format(c.asprevtime,'%Y-%m-%d %H:%i:%s') as prevtime,
					date_format(c.asopentime,'%Y-%m-%d %H:%i:%s') as starttime,
					date_format(c.asclosetime,'%Y-%m-%d %H:%i:%s') as endtime,
					if(c.asprevtime>now(),'-1',if(c.asprevtime<now() and c.asprevclosetime>now(),0,if(c.asopentime<now() and c.asclosetime>now(),1,2))) as auctiontype,
					c.astag as atag,
					a.aid,
					a.acode,
					a.auction,
					if((a.lastprice=0),1.00,a.lastprice) as lastprice,
					a.lasttime
					from
						auction a
						inner join auction_special c on a.asid=c.asid
					where c.astag > 0 and aid in (".$aids.") order by a.acode asc";
	$dbf = $GLOBALS['dbf'];
	return $dbf->queryArray($sql);
 }
 
	/**
	 * 电话号中间变成 *
	 */
	function user_fix_mobile($mobile){
		$size = strlen($mobile); //手机号长度
		if($size<6){
			return "******";
		}
		$xing = "";
		for($i=0;$i<($size-6);$i++){
			$xing = $xing."*";
		}
		return substr($mobile,0,3).$xing.substr($mobile,($size-3),3);
	}
 ?>